package com.xinfu.newproject.adapter.park_adapter;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.google.gson.Gson;
import com.xinfu.newproject.R;
import com.xinfu.newproject.activity.ParkingActivity;
import com.xinfu.newproject.bean.park_bean.bean.GetMonthCarListBean;
import com.xinfu.newproject.ui.carFee.add_parking.MonthParkRecordActivity;
import com.xinfu.newproject.ui.carFee.add_parking.ParkingDetailActivity;
import com.xinfu.newproject.ui.carFee.add_parking.ParkingTopUpActivity;
import com.xinfu.newproject.util.DateFormatUtils;

/**
 *
 */
public class MonthCardAdapter extends BaseQuickAdapter<GetMonthCarListBean.ResultBean, BaseViewHolder> {

    TextView nameTv, timeTv, priceTv, carId;

    public MonthCardAdapter() {
        super(R.layout.item_month_card, null);
    }

    @Override
    protected void convert(BaseViewHolder helper, GetMonthCarListBean.ResultBean item) {
        helper.setText(R.id.item_month_card_park_lot, "车场名称: " + item.getParkName());
        helper.setText(R.id.item_month_card_park_name_tv, "车主姓名: " + item.getOwner());
        helper.setText(R.id.item_month_card_park_car_id, "车牌号码: " + item.getCarId());
        if (item.getCheckStatus() == -2) {
            helper.setText(R.id.item_month_card_park_audit_status, "审核失效");
            helper.setTextColor(R.id.item_month_card_park_audit_status, mContext.getResources().getColor(R.color.text_status_error));
        } else if (item.getCheckStatus() == -1) {
            helper.setText(R.id.item_month_card_park_audit_status, "审核未通过");
            helper.setTextColor(R.id.item_month_card_park_audit_status, mContext.getResources().getColor(R.color.text_status_error));
        } else if (item.getCheckStatus() == 0) {
            helper.setText(R.id.item_month_card_park_audit_status, "待审核");
            helper.setTextColor(R.id.item_month_card_park_audit_status, mContext.getResources().getColor(R.color.text_status_ing));
        } else if (item.getCheckStatus() == 1) {
            helper.setText(R.id.item_month_card_park_audit_status, "审核通过");
            helper.setTextColor(R.id.item_month_card_park_audit_status, mContext.getResources().getColor(R.color.text_status_finish));
        }
        helper.setText(R.id.item_month_card_park_time, DateFormatUtils.getNormalTimeString(item.getLocalEndTime(), "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd"));
        if (item.getCheckStatus() == 1) {
            helper.setTextColor(R.id.item_month_card_park_renew_delay, mContext.getResources().getColor(R.color.yellow_ff));
            helper.setTextColor(R.id.item_month_card_park_renew_record, mContext.getResources().getColor(R.color.yellow_ff));
            helper.setBackgroundRes(R.id.item_month_card_park_renew_delay, R.drawable.choose_no_bg);
            helper.setBackgroundRes(R.id.item_month_card_park_renew_record, R.drawable.choose_no_bg);
            helper.getView(R.id.item_month_card_park_renew_delay).setEnabled(true);
            helper.getView(R.id.item_month_card_park_renew_record).setEnabled(true);
        } else {
            helper.setTextColor(R.id.item_month_card_park_renew_delay, mContext.getResources().getColor(R.color.gray_a5));
            helper.setTextColor(R.id.item_month_card_park_renew_record, mContext.getResources().getColor(R.color.gray_a5));
            helper.setBackgroundRes(R.id.item_month_card_park_renew_delay, R.drawable.no_bg_edit_normal);
            helper.setBackgroundRes(R.id.item_month_card_park_renew_record, R.drawable.no_bg_edit_normal);
            helper.getView(R.id.item_month_card_park_renew_delay).setEnabled(false);
            helper.getView(R.id.item_month_card_park_renew_record).setEnabled(false);
        }
        helper.getView(R.id.item_month_card_park_audit_detail).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Bundle bundle = new Bundle();
                bundle.putString("response", new Gson().toJson(item));
                ((ParkingActivity) mContext).startIntentActivity(ParkingDetailActivity.class, bundle);
            }
        });
        helper.getView(R.id.item_month_card_park_renew_delay).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Bundle bundle = new Bundle();
                bundle.putString("response", new Gson().toJson(item));
                ((ParkingActivity) mContext).startIntentActivity(ParkingTopUpActivity.class, bundle);
            }
        });
        helper.getView(R.id.item_month_card_park_renew_record).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Bundle bundle = new Bundle();
                bundle.putString("tenantId", item.getTenantId());
                bundle.putString("parkCarId", item.getId());
                bundle.putString("carParkName", item.getParkName());
                bundle.putString("ownerName", item.getOwner());
                bundle.putString("carNum", item.getCarId());
                ((ParkingActivity) mContext).startIntentActivity(MonthParkRecordActivity.class, bundle);
            }
        });

    }



}
